package tasoloikka;

import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;

public class ActionListener implements KeyListener, MouseListener, MouseMotionListener {

  private Game game;
  public boolean arrowUp = false;
  public boolean arrowDown = false;
  public boolean arrowLeft = false;
  public boolean arrowRight = false;
  public boolean space;
  public boolean shift;
  public boolean mouseClicked;
  public boolean buttonK;
  public int mouseX;
  public int mouseY;
  public boolean realArrowRight;
  public boolean realArrowLeft;

  @Override
  public void keyTyped(KeyEvent e) {
  }

  @Override
  public void keyPressed(KeyEvent e) {
    switch (e.getKeyCode()) {
      case KeyEvent.VK_W:
        arrowUp = true;
        break;

      case KeyEvent.VK_S:
        arrowDown = true;
        break;

      case KeyEvent.VK_A:
        arrowLeft = true;
        break;

      case KeyEvent.VK_D:
        arrowRight = true;
        break;

      case KeyEvent.VK_SPACE:
        space = true;
        break;

      case KeyEvent.VK_SHIFT:
        shift = true;
        break;

      case KeyEvent.VK_K:
        game.buttonK();
        break;

      case KeyEvent.VK_RIGHT:
        game.rightButton();
        break;
        
      case KeyEvent.VK_LEFT:
        game.leftButton();
        break;

      default:
        break;
    }
  }

  @Override
  public void keyReleased(KeyEvent e) {
    switch (e.getKeyCode()) {
      case KeyEvent.VK_W:
        arrowUp = false;
        break;

      case KeyEvent.VK_S:
        arrowDown = false;
        break;

      case KeyEvent.VK_A:
        arrowLeft = false;
        break;

      case KeyEvent.VK_D:
        arrowRight = false;
        break;

      case KeyEvent.VK_SPACE:
        space = false;
        break;

      case KeyEvent.VK_SHIFT:
        shift = false;
        break;

      case KeyEvent.VK_K:
        break;

      default:
        break;
    }
  }

  public void mouseClicked(MouseEvent e) {
  }

  public void mousePressed(MouseEvent e) {
    mouseClicked = true;
  }

  public void mouseReleased(MouseEvent e) {
  }

  public void mouseEntered(MouseEvent e) {
  }

  public void mouseExited(MouseEvent e) {
  }

  public void mouseDragged(MouseEvent e) {
  }

  public void mouseMoved(MouseEvent e) {
    mouseX = e.getX();
    mouseY = e.getY();
  }

  public void setGame(Game game) {
    this.game = game;
  }
}
